

import 'package:base_flutter/common/global.dart';
import 'package:base_flutter/models/index.dart';
import 'package:flutter/material.dart';

class BaseChangeNotifier extends ChangeNotifier {

  Profile get _profile => Global.profile;

  @override
  void notifyListeners() {
    // TODO: implement notifyListeners
    Global.saveProfile();
    super.notifyListeners();
  }
}

class UserModel extends BaseChangeNotifier {

  User? get user => _profile.user;

  bool get isLogin => user != null;

  set user(User? user) {
      if (user?.phone != _profile.user?.phone) {
        _profile.user = user;
        notifyListeners();
      }
  }
}

class UserLocation extends BaseChangeNotifier {

  User_location? get location => _profile.location;

  set location(User_location? location) {
    _profile.location = location;
    notifyListeners();
  }
}